<template>
    <view class="container">
        <view class="proline">
            <view class="cu-steps">
                <view :class="'cu-item ' + (guestinfo.pstatus >= 0 ? 'text-blue' : '') + ' '">
                    <text class="num" data-index="0"></text>
                    面试
                </view>

                <view :class="'cu-item ' + (guestinfo.pstatus >= 1 ? 'text-blue' : '') + '  '">
                    <text class="num" data-index="1"></text>
                    录用
                </view>

                <view :class="'cu-item ' + (guestinfo.pstatus >= 2 ? 'text-blue' : '') + '  '">
                    <text class="num" data-index="2"></text>
                    试用
                </view>
                <view :class="'cu-item ' + (guestinfo.pstatus >= 3 ? 'text-blue' : '') + '  '">
                    <text class="num" data-index="3"></text>
                    录用
                </view>
                <view :class="'cu-item ' + (guestinfo.pstatus >= 4 ? 'text-blue' : '') + '  '">
                    <text class="num" data-index="4"></text>
                    完成
                </view>
            </view>
        </view>

        <view class="jobdetail">
            <view class="jobtitle" style="padding-left: 20rpx">报备流水</view>
        </view>

        <view class="cu-timeline" v-for="(item, index) in proguestlist" :key="index">
            <view class="cu-time">{{ item.createtime }}</view>

            <view class="cu-item">
                <view class="content">
                    <text>{{ item.title }} {{ item.content }}</text>
                </view>
            </view>
        </view>

        <form @submit="toAgreeorder" report-submit v-if="guestinfo.status == 0">
            <view class="main">
                <view class="title">求职进度</view>
                <view class="list">
                    <view class="item">
                        <view class="selectitem">
                            <radio-group class="radio-group" @change="radioAgreeChange">
                                <label class="radio">
                                    <radio value="1" checked="" />
                                    同意面试
                                </label>
                                <label class="radio">
                                    <radio value="-1" checked="" />
                                    拒绝面试
                                </label>
                            </radio-group>
                        </view>
                    </view>
                    <view class="item">
                        <view class="selectitem">
                            <textarea name="content" placeholder="填写备注说明" value="" maxlength="-1" />
                        </view>
                    </view>
                </view>
            </view>

            <view class="weixinmao-float" style="margin-bottom: 30rpx">
                <view class="weixinmao-foot">
                    <button class="footer" formType="submit">提交进度</button>
                </view>
            </view>
        </form>

        <form @submit="toPassorder" report-submit v-if="guestinfo.status == 1">
            <view class="main">
                <view class="title">求职进度</view>
                <view class="list">
                    <view class="item">
                        <view class="selectitem">
                            <radio-group class="radio-group" @change="radioAgreeChange">
                                <label class="radio">
                                    <radio value="2" checked="" />
                                    面试成功
                                </label>
                                <label class="radio">
                                    <radio value="-2" checked="" />
                                    面试失败
                                </label>
                            </radio-group>
                        </view>
                    </view>
                    <view class="item">
                        <view class="selectitem">
                            <textarea name="content" placeholder="填写备注说明" value="" maxlength="-1" />
                        </view>
                    </view>
                </view>
            </view>

            <view class="weixinmao-float" style="margin-bottom: 30rpx">
                <view class="weixinmao-foot">
                    <button class="footer" formType="submit">提交进度</button>
                </view>
            </view>
        </form>

        <form @submit="toTypeinorder" report-submit v-if="guestinfo.status == 2">
            <view class="main">
                <view class="title">求职进度</view>
                <view class="list">
                    <view class="item">
                        <view class="selectitem">
                            <radio-group class="radio-group" @change="radioAgreeChange">
                                <label class="radio">
                                    <radio value="3" checked="" />
                                    录用成功
                                </label>
                                <label class="radio">
                                    <radio value="-3" checked="" />
                                    录用失败
                                </label>
                            </radio-group>
                        </view>
                    </view>
                    <view class="item">
                        <view class="selectitem">
                            <textarea name="content" placeholder="填写备注说明" value="" maxlength="-1" />
                        </view>
                    </view>
                </view>
            </view>

            <view class="weixinmao-float" style="margin-bottom: 30rpx">
                <view class="weixinmao-foot">
                    <button class="footer" formType="submit">提交进度</button>
                </view>
            </view>
        </form>

        <form @submit="toTryorder" report-submit v-if="guestinfo.status == 3">
            <view class="main">
                <view class="title">求职进度</view>
                <view class="list">
                    <view class="item">
                        <view class="selectitem">
                            <radio-group class="radio-group" @change="radioAgreeChange">
                                <label class="radio">
                                    <radio value="4" checked="" />
                                    试用成功
                                </label>
                                <label class="radio">
                                    <radio value="-4" checked="" />
                                    试用失败
                                </label>
                            </radio-group>
                        </view>
                    </view>
                    <view class="item">
                        <view class="selectitem">
                            <textarea name="content" placeholder="填写备注说明" value="" maxlength="-1" />
                        </view>
                    </view>
                </view>
            </view>

            <view class="weixinmao-float" style="margin-bottom: 30rpx">
                <view class="weixinmao-foot">
                    <button class="footer" formType="submit">提交进度</button>
                </view>
            </view>
        </form>

        <form @submit="toDoneorder" report-submit v-if="guestinfo.status == 4">
            <view class="main">
                <view class="title">求职进度</view>
                <view class="list">
                    <view class="item">
                        <view class="selectitem">
                            <radio-group class="radio-group" @change="radioAgreeChange">
                                <label class="radio">
                                    <radio value="5" checked="" />
                                    完成正式入职
                                </label>
                                <label class="radio">
                                    <radio value="-5" checked="" />
                                    入职失败
                                </label>
                            </radio-group>
                        </view>
                    </view>
                    <view class="item">
                        <view class="selectitem">
                            <textarea name="content" placeholder="填写备注说明" value="" maxlength="-1" />
                        </view>
                    </view>
                </view>
            </view>

            <view class="weixinmao-float" style="margin-bottom: 30rpx">
                <view class="weixinmao-foot">
                    <button class="footer" formType="submit">提交进度</button>
                </view>
            </view>
        </form>
    </view>
</template>

<script>
import { Company } from '../../model/company-model.js';
var company = new Company();
import { Jobrecord } from '../../model/jobrecord-model.js';
var jobrecord = new Jobrecord();
export default {
    data() {
        return {
            id: 0,
            status: -8,
            donestatus: '处理',

            guestinfo: {
                pstatus: 0,
                status: 0
            },

            proguestlist: '',
            houseinfo: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (e) {
        this.onLoadClone3389(e);
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    methods: {
        /**
         * 生命周期函数--监听页面加载
         */
        onLoadClone3389: function (e) {
            var that = this;
            if (that.id > 0) {
                var id = that.id;
            } else {
                var id = e.id;
                that.id = e.id;
            }
            var params = {
                id: that.id
            };
            company.sendorderdetail((data) => {
                uni.setNavigationBarTitle({
                    title: '求职进度处理'
                });
                that.setData({
                    guestinfo: data.guestinfo,
                    proguestlist: data.proguestlist,
                    houseinfo: data.houseinfo
                });
                uni.hideNavigationBarLoading(); //完成停止加载
                uni.stopPullDownRefresh();
            }, params);
        },

        doCall: function (e) {
            console.log(e.currentTarget);
            var tel = e.currentTarget.dataset.tel;
            uni.makePhoneCall({
                phoneNumber: tel,
                //此号码并非真实电话号码，仅用于测试
                success: function () {
                    console.log('拨打电话成功！');
                },
                fail: function () {
                    console.log('拨打电话失败！');
                }
            });
        },

        toNotedetail: function (e) {
            var id = e.currentTarget.dataset.id;
            uni.navigateTo({
                url: '/pages/workerdetail/index?id=' + id
            });
        },

        radioAgreeChange: function (e) {
            this.status = e.detail.value;
        },

        toSendorder: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var money = e.detail.value.money;
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: 5,
                            content: content,
                            money: money
                        };
                        jobrecord.doSendjobrecordorder((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toContact: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doJobrecordContact((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toWork: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doWork((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toAgreeorder: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doAgree((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toPassorder: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doPass((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toTypeinorder: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doTypein((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toTryorder: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doTry((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toDoneorder: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doDone((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toCancleorder: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doCancle((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toUseWork: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doUseWork((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toInivateNote: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doInivateNote((data) => {
                            if (data.status == 0) {
                                that.onLoadClone3389({});
                            }
                        }, params);
                    }
                }
            });
        },

        toDoneall: function (e) {
            var that = this;
            console.log(that.id);
            uni.showModal({
                title: '提交',
                content: '确认提交？',
                success: function (res) {
                    if (res.confirm) {
                        var content = e.detail.value.content;
                        var params = {
                            id: that.id,
                            status: that.status,
                            content: content
                        };
                        jobrecord.doDoneall((data) => {
                            if (data.status == 0) {
                                uni.navigateBack({
                                    delta: 1
                                });
                            }
                        }, params);
                    }
                }
            });
        }
    }
};
</script>
<style>
.main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.main .title {
    width: 730rpx;
    padding-top: 15rpx;
    padding-bottom: 15rpx;
    font-size: 0.9rem;
    padding-left: 20rpx;
    color: #888888;
}

.main .list {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
}

.main .list .item {
    width: 700rpx;
    border-bottom: 1rpx solid #f5f5f5;
    align-self: center;
    padding-top: 20rpx;
    padding-bottom: 20rpx;
    display: flex;
    flex-direction: column;
}
.main .list .item .name {
    font-size: 16px;
    color: #a2a2a2;
}
.main .list .item .selectitem {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    color: #808080;
    font-size: 14px;

    background: #fff;
}

.weixinmao-foot {
    display: flex;
    justify-content: center;
    flex-direction: row;

    width: 100%;
    margin-top: 30rpx;
}

.weixinmao-foot view {
    color: #fff;
    align-self: center;
    height: 100rpx;
    line-height: 100rpx;
    font-size: 0.9rem;
    display: flex;
    flex-direction: row;
    width: 50%;
    border-radius: 0rpx;
    padding-left: 30rpx;
    background: #e64340;
}
.weixinmao-foot button {
    background: #ff9003;
    width: 85%;
    color: #fff;
    border-radius: 5rpx;
    font-size: 1rem;
}

.black {
    color: #777676;
}
.red {
    color: red;
}
.weixinmao-foot view:nth-child(3) {
    color: #fff;
    align-self: center;
    height: 100rpx;
    line-height: 100rpx;
    text-align: center;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    background: #fe552e;
    width: 55%;
    border-radius: 5rpx;
}

.weixinmao-foot view image {
    width: 50rpx;
    height: 50rpx;
    align-self: center;
}

.footerbutton {
    background: #fe552e;
}

.proline {
    width: 100%;
    padding-top: 20rpx;

    background: #ffffff;

    padding-bottom: 20rpx;
}

.weixinmao-foot {
    display: flex;
    justify-content: center;
    flex-direction: row;

    width: 100%;
    margin-top: 30rpx;
}

.weixinmao-foot view {
    color: #fff;
    align-self: center;
    height: 100rpx;
    line-height: 100rpx;
    font-size: 0.9rem;
    display: flex;
    flex-direction: row;
    width: 50%;
    border-radius: 0rpx;
    padding-left: 30rpx;
    background: #e64340;
}
.weixinmao-foot button {
    background: #ff9003;
    width: 85%;
    color: #fff;
    border-radius: 5rpx;
    font-size: 1rem;
}

button::after {
    border: none;
}
</style>
